package cn.yunhe.service;

import cn.yunhe.dao.MemberDao;
import cn.yunhe.pojo.Member;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

public class MemberService {
    SqlSession session=null;
    MemberDao memberDao=null;

    /**
     * 初始化
     */
    public void initial(){
        session=SqlSessionFactoryUtil.getSqlSession();
        memberDao=session.getMapper(MemberDao.class);
    }

    /**
     * 销毁
     */
    public void destory(){
        if (session!=null){
            session.commit();
            session.close();
        }
    }


    public boolean register(Member member){
        initial();
        boolean flag= memberDao.register(member);
        destory();
        return flag;
    }

    public Member login(Member member){
        initial();
        Member member1=memberDao.login(member);
        destory();
        return member1;
    }


}
